Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MM-228] Add feature to update custom status and status of the user during meeting #359

Merged
merged 23 commits into from
Aug 13, 2024

Conversation

raghavaggarwal2308
Copy link
Contributor

@raghavaggarwal2308 raghavaggarwal2308 commented Mar 4, 2024

Recreating this PR with the changes of #355 because of a lot of merge conflicts on that PR

Summary

  • Added feature to update custom status of the user during meeting
  • Added feature to set status of the user from the options provided in the dropdown during the meeting

Ticket Link

#228

Screenshots

image
image

What to test?

  • Custom status gets updated during a meeting.
  • User status gets updated to the selected value during a meeting.
  • No change in user status during overlapping meetings or when there are no attendees.
  • No change of user custom status during overlapping meetings, when there are no attendees, or when there is already a custom status set.

How to test?

  • Create a meeting in the MS Calendar.
  • Run slash command /mscalendar settings, select an option from the Update Status setting, and check the updated status on the Mattermost.
  • Run slash command /mscalendar settings, set the Set Custom Status setting to yes, and check the updated custom status on the Mattermost.

@codecov-commenter
Copy link

codecov-commenter commented Mar 4, 2024

Codecov Report

Attention: Patch coverage is 46.55172% with 62 lines in your changes are missing coverage. Please review.

Project coverage is 21.92%. Comparing base (7f1bbcd) to head (642b212).

Files Patch % Lines
calendar/engine/availability.go 57.44% 30 Missing and 10 partials ⚠️
calendar/engine/welcome_flow.go 0.00% 11 Missing ⚠️
calendar/engine/settings.go 0.00% 9 Missing ⚠️
calendar/engine/welcomer.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #359      +/-   ##
==========================================
+ Coverage   20.94%   21.92%   +0.98%     
==========================================
  Files          67       67              
  Lines        3442     3525      +83     
==========================================
+ Hits          721      773      +52     
- Misses       2628     2652      +24     
- Partials       93      100       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hanzei
Copy link
Collaborator

hanzei commented Mar 5, 2024

I'm not too knowldeage with this plugin. @mickmister @fmartingr would you mind reviewing the PR?

@hanzei hanzei added 2: Dev Review Requires review by a core committer 3: QA Review Requires review by a QA tester labels Mar 5, 2024
Copy link
Contributor

@fmartingr fmartingr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems the same as I reviewed back in #355 👍

@mickmister
Copy link
Contributor

@AayushChaudhary0001 Can you please take a look at this PR when you have the chance? Thanks

Copy link
Contributor

@mickmister mickmister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work @raghavaggarwal2308 👍

I have some comments for discussion

calendar/engine/availability.go Outdated Show resolved Hide resolved
calendar/engine/availability.go Outdated Show resolved Hide resolved
calendar/engine/availability.go Outdated Show resolved Hide resolved
Comment on lines 350 to 353
// Not setting custom status for events without attendees since those are unlikely to be meetings.
if len(events[0].Attendees) < 1 {
return "No attendee present, not setting custom status", isStatusChanged, nil
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if a meeting other than the first one has attendees?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This flow is updated now. We consider other meetings as well now.

calendar/engine/availability.go Outdated Show resolved Hide resolved
@@ -56,15 +56,18 @@ func (wf *WelcomeFlow) FlowDone(userID string) {

func (wf *WelcomeFlow) makeSteps() {
steps := []flow.Step{
&flow.EmptyStep{
Title: "Update Status",
Message: "You can update your status to \"Away\" or \"Do not disturb\" when you're in a meeting by typing `/mscalendar settings`.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This original wording makes me think it's telling me to run /mscalendar settings while I'm in a meeting

Suggested change
Message: "You can update your status to \"Away\" or \"Do not disturb\" when you're in a meeting by typing `/mscalendar settings`.",
Message: "You can type `/mscalendar settings` to configure the plugin to update your status to \"Away\" or \"Do not disturb\" when you're in a meeting.",

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use ProviderConfig.Command here instead of a fixed /mscalendar?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fmartingr I wonder if this is something we can configure the linter to catch?

Comment on lines +183 to +193
e.Dependencies.Tracker = tracker.New(
telemetry.NewTracker(
p.telemetryClient,
p.API.GetDiagnosticId(),
p.API.GetServerVersion(),
e.PluginID,
e.PluginVersion,
config.Provider.TelemetryShortName,
telemetry.NewTrackerConfig(p.API.GetConfig()),
telemetry.NewLogger(p.API),
),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. So we haven't been tracking telemetry?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was no else condition present in the block in case e.Dependencies.Tracker is nil. So added the else condition as well.

calendar/store/user_store.go Show resolved Hide resolved
Comment on lines 338 to 344
"SetCustomStatus enabled but overlapping events": {
settings: store.Settings{
SetCustomStatus: true,
},
runAssertions: func(deps *Dependencies, client remote.Client) {
c, papi, _, _, r := client.(*mock_remote.MockClient), deps.PluginAPI.(*mock_plugin_api.MockPluginAPI), deps.Poster.(*mock_bot.MockPoster), deps.Store.(*mock_store.MockStore), deps.Remote.(*mock_remote.MockRemote)
moment := time.Now().UTC()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if I have a meeting in the next hour, and in the following hour after that I have two meetings that overlap. Will this make it so the first meeting (which in this case does not overlap) doesn't trigger a status update? Can we have a test made for this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case is updated now and we are handling overlapping events now.

calendar/engine/availability_test.go Show resolved Hide resolved
@mickmister
Copy link
Contributor

From the discussion #228 (comment), it seems we should still change the user's status when there are overlapping meetings. We want to emulate real life as much as possible. If there is an event where I'm a (confirmed?) attendee, and there are other attendees, then the user's status should change

@mickmister
Copy link
Contributor

Hi @raghavaggarwal2308 just checking in. Do you or another dev plan to continue work on this PR?

@raghavaggarwal2308
Copy link
Contributor Author

Hi @raghavaggarwal2308 just checking in. Do you or another dev plan to continue work on this PR?

@mickmister Yeah, we will pick this up asap. Apologies for the delay.

@ayusht2810 ayusht2810 requested a review from wiggin77 as a code owner July 4, 2024 12:19
@ayusht2810
Copy link
Contributor

@mickmister Fixed the review comment. Please re-review

@@ -110,7 +110,7 @@ func (m *mscalendar) retrieveUsersToSync(userIndex store.UserIndex, syncJobSumma
}

// If user does not have the proper features enabled, just go to the next one
if !(user.Settings.UpdateStatusFromOptions != NotSetStatusOption || user.Settings.ReceiveReminders || user.Settings.SetCustomStatus) {
if !(user.IsConfiguredForStatusUpdates() || user.IsConfiguredForCustomStatusUpdates() || user.Settings.ReceiveReminders) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would expect these methods to be defined on user.Settings, though I don't think it matters. This current way allows for less typing throughout the usages of the method

calendar/engine/availability.go Outdated Show resolved Hide resolved
calendar/engine/availability.go Show resolved Hide resolved
Comment on lines 666 to 675
for i := 1; i < len(events); i++ {
if events[i-1].End.Time().UnixMicro() > events[i].Start.Time().UnixMicro() {
return true
if (events[idx].End.Time().UnixMicro() >= events[i].Start.Time().UnixMicro()) || (events[idx].End.Time().Sub(events[idx].Start.Time()) <= StatusSyncJobInterval && events[i].Start.Time().Sub(events[idx].End.Time()) <= StatusSyncJobInterval) {
events[idx].End = events[i].End
} else {
idx++
events[idx] = events[i]
}
}

return false
return events[0 : idx+1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to put the body of this loop in its own function, and have it unit tested to show/document how it works

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mickmister Added a comment to it. I don't think we need to separately test the function as it is already covered by its parent function.

@@ -856,3 +1025,161 @@ func makeStatusSyncTestEnv(ctrl *gomock.Controller) (Env, remote.Client) {

return env, mockClient
}

func TestGetMergedEvents(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the function is tested here 👍

@mickmister mickmister removed the 2: Dev Review Requires review by a core committer label Jul 10, 2024
@mickmister
Copy link
Contributor

Hi @AayushChaudhary0001, can you please review this when you have a chance?

@ayusht2810
Copy link
Contributor

@mickmister Fixed the review fixes. Please re-review.

@arush-vashishtha
Copy link

@raghavaggarwal2308 I found two issue while testing this PR

Issue 01: Wrong text is shown for the status change.

Steps to reproduce:

  1. Enable the MS calendar plugin
  2. Open the ms calendar settings for Mattermost server via slash command
  3. Then set 'Setting: Get Confirmation' to Yes
  4. Also set 'Setting: Set Custom Status' to Yes
  5. Now schedule a meeting from outlook calendar
  6. Check the text shown for status change message.

Expected: Appropriate and accurate text should be shown.
Actual: Wrong text is shown for the status change.

SS for the reference:
image

Issue 02: Custom status is not getting updated properly

Steps to reproduce:

  1. Enable the MS calendar plugin
  2. Create two overlapping meeting from outlook calendar like - one from 10:00 am to 10:15 am and second from 10:15 am to 10:30 am
  3. Check the custom status for second meeting

Expected: No delay should be there in updating the custom status of the second meeting
Actual: Around 4 min delay is found for the updation of custom status for the second meeting

@wiggin77
Copy link
Member

wiggin77 commented Aug 8, 2024

@raghavaggarwal2308 I didn't realize this PR was needed for the custom status in Google Calendar plugin as well. We have a customer waiting on the GCal part. We'll need to test and merge this despite wanting to avoid big changes in MSCal, unless there is a better solution.

@raghavaggarwal2308
Copy link
Contributor Author

@wiggin77 Sure, we will work on this PR on priority. Also, the issue in mscalendar plugin has been fixed now. We have also got the confirmation from the customer who was facing the issue earliar.

@raghavaggarwal2308 raghavaggarwal2308 added this to the v1.3.0 milestone Aug 9, 2024
@raghavaggarwal2308
Copy link
Contributor Author

@AayushChaudhary0001 @arush-vashishtha The issues reported above are very rare edge cases. These are happening because our job to update status is running in every 5 mins. So, when two meetings are very close there might be some inconsistencies rarely. I think we should create a new issue for this particular case and spend time on this there. As this is out of scope for this PR.

@AayushChaudhary0001
Copy link

Approved this PR because the bug found are possibly out of the scope of this PR, these might be due to the time interval for updating the status by the job. Rest everything looks working fine in this PR(updating the custom status).
Created a new issue regarding for the above #393

@raghavaggarwal2308 raghavaggarwal2308 removed the 3: QA Review Requires review by a QA tester label Aug 13, 2024
@raghavaggarwal2308 raghavaggarwal2308 merged commit 1589e57 into master Aug 13, 2024
6 checks passed
@raghavaggarwal2308 raghavaggarwal2308 deleted the MM-188-fix branch August 13, 2024 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants